<template>
  <div>
    <el-form-item label="表单格式">
      <el-select v-model="localData.dynamicType" @change="localData.dynamicModel = ''">
        <el-option label="表格" value="table" />
        <el-option label="表单" value="form" />
      </el-select>
    </el-form-item>
    <el-form-item label="表单模式">
      <el-select v-model="localData.dynamicModel">
        <el-option label="平铺" value="common" />
        <!-- 因技术力原因目前只在表格格式下支持弹框模式 -->
        <el-option v-if="localData.dynamicType == 'table'" label="弹框" value="dialog" />
      </el-select>
    </el-form-item>
    <el-form-item label="最大项数">
      <el-input-number v-model="localData.limit" placeholder="请输入" controls-position="right" />
    </el-form-item>
    <el-form-item label="按钮文本">
      <el-input v-model="localData.btnContent" placeholder="请输入" />
    </el-form-item>
    <el-form-item label="excel导入">
      <el-switch v-model="localData.showExcelImport" />
    </el-form-item>
  </div>
</template>

<script>
export default {
  name: 'AnvilDynamicConfig',
  props: {
    data: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      localData: {}
    }
  },
  watch: {
    data: {
      handler(newVal) {
        if (newVal) {
          this.localData = newVal
        }
      },
      deep: true,
      immediate: true
    },
    localData: {
      handler(newVal) {
        this.$emit('update:data', newVal)
      },
      deep: true
    }
  }
}
</script>

<style scoped></style>
